﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PMS.ENT;
using PMS.DAL;

namespace PMS.BLL
{
    public class UserBLL
    {
        #region Get
        public static UserENT GetUserByID(int userID)
        {
            try
            {
                return UserDAL.GetUserByID(userID);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static UserCollection GetUserByIDAndGroupID(int userID, int groupID)
        {
            try
            {
                return UserDAL.GetUserByIDAndGroupID(userID,groupID);
            }
            catch (Exception)
            {
                
                throw;
            }
        }
        public static UserENT GetUserByUserCode(string userCode)
        {
            try
            {
                return UserDAL.GetUserByUserCode(userCode);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public static UserENT GetUserByEmail(string email)
        {
            try
            {
                return UserDAL.GetUserByEmail(email);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public static UserENT GetUserByUserName(string userName)
        {
            try
            {
                return UserDAL.GetUserByUserName(userName);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static UserCollection GetUserList(string fullName, int departmentID, int roleID, string orderBy, string orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                return UserDAL.GetUserList(fullName, departmentID, roleID, orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static UserCollection GetUserListForCMB(int roleID)
        {
            try
            {
                UserCollection listUser = new UserCollection();
                listUser.Add(new UserENT { UserID = 0, UserName = "--All--" });
                listUser.AddRange(UserDAL.GetUserListForCMB(roleID));
                return listUser;
            }
            catch (Exception)
            {

                throw;
            }
        }




        #endregion

        #region Insert Update Delete Confirm

        public static int InsertUser(UserENT user)
        {
            try
            {
                return UserDAL.InsertUser(user);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int UpdateUser(UserENT user)
        {
            try
            {
                return UserDAL.UpdateUser(user);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int DeleteUser(string strUserID, int userID)
        {
            try
            {
                return UserDAL.DeleteUser(strUserID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }




        #endregion


    }
}
